﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ExtraOpdrachten
{
    public partial class Opdracht7 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnCalculateBMI_Click(object sender, EventArgs e)
        {
            double length;
            double weight;
            double bmi;
            if(!double.TryParse(txtLength.Text , out length))
            {
                lblResult.Text = "Ongeldige waarde voor lengte";
                txtLength.Text = string.Empty;
                txtLength.Focus();
                return;
            }
            length /= 100;
            if (!double.TryParse(txtWeight.Text, out weight))
            {
                lblResult.Text = "Ongeldige waarde voor gewicht";
                txtWeight.Text = string.Empty;
                txtWeight.Focus();
                return;
            }
            bmi = weight / Math.Pow(length, 2);
            lblResult.Text = string.Format("Uw BMI is {0:n2}", bmi);

        }
    }
}